#include "formfsnavigation.h"
#include "ui_formfsnavigation.h"
#include <QDebug>


//--------------------------------------------------------------------------------------------------------------------------------------------------------------


FormFSNavigation::FormFSNavigation(QWidget *parent) :
    QWidget(parent),
    mp_fs_view(NULL),
    mp_fs_model(NULL),
    ui(new Ui::FormFSNavigation)
{
    ui->setupUi(this);

    connect(ui->btn_up, SIGNAL(clicked()), SLOT(dir_up()));
}

//--------------------------------------------------------------------------------------------------------------------------------------------------------------

FormFSNavigation::~FormFSNavigation()
{
    delete ui;
}

//--------------------------------------------------------------------------------------------------------------------------------------------------------------

void FormFSNavigation::set_table_view(SleeFSView *p_tv)
{
    if(mp_fs_view)
    {
        if(mp_fs_model)
        {
            disconnect(mp_fs_model, SIGNAL(rootPathChanged(QString)), this, SLOT(root_changed(QString)));
        }
    }
    mp_fs_view = p_tv;
    mp_fs_model = dynamic_cast<SleeFSModel *>(mp_fs_view->model());
    connect(mp_fs_model, SIGNAL(rootPathChanged(QString)), SLOT(root_changed(QString)));
}

//--------------------------------------------------------------------------------------------------------------------------------------------------------------

void FormFSNavigation::root_changed(QString qstr_path)
{
    ui->ledit_root_path->setText(qstr_path);
}

//--------------------------------------------------------------------------------------------------------------------------------------------------------------

void FormFSNavigation::dir_up()
{
    if(!mp_fs_model) return;
    mp_fs_view->directory_up();
}

//--------------------------------------------------------------------------------------------------------------------------------------------------------------
